package com.dong.es.entity.searchparam.query.range;


import com.dong.es.entity.EsBaseDTO;
import com.dong.es.entity.searchparam.query.EsQueryParam;
import org.apache.commons.lang3.StringUtils;

/**
 * @description: Es 范围查询参数
 * @author: 陈瑞东
 * @create: 2022-06-23 11:24
 */
public abstract class EsRangeQueryParam<T> extends EsQueryParam {
    private static final long serialVersionUID = -7487096669704126494L;

    protected String field;
    protected T start;
    protected T end;

    public EsRangeQueryParam(String field, T start, T end) {
        this.field = field;
        this.start = start;
        this.end = end;
    }

    @Override
    protected boolean valid(EsBaseDTO esBaseDTO) {
        return StringUtils.isNotBlank(field) && start != null && end != null;
    }

    @Override
    protected void addMethod(EsBaseDTO esBaseDTO) {
        esBaseDTO.query(this);
    }
}
